package com.settlement.system.converter;

import com.alibaba.excel.converters.AutoConverter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.settlement.system.common.enums.NcAccountStatusEnum;
import org.apache.commons.lang3.StringUtils;

/**
 * 记账状态
 * @author author
 */
public class NcAccountStatusConvert extends AutoConverter {

    @Override
    public WriteCellData convertToExcelData(Object value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {

        if(value!=null && !StringUtils.isEmpty(value.toString())){
            return new WriteCellData(NcAccountStatusEnum.getName(Integer.parseInt(value.toString())));
        }
        return new WriteCellData("");
    }

    @Override
    public Object convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return super.convertToJavaData(cellData, contentProperty, globalConfiguration);
    }
}
